#include <iostream>
#include <vector>
#include <cmath>
using std::cin;
using std::cout;
using std::vector;
using std::istream;
using std::ostream;

const float PI = 3.1415926535897935384626;

/// 限制区（红圈表示），包含坐标和半径
struct RestrictedArea
{
    float x;
    float z;
    float radius;
};

istream &operator>>(istream &in, RestrictedArea &var)
{
    in >> var.x >> var.z >> var.radius;
    return in;
}

/// 初始信息，每局游戏只会接收一次
struct ReceiveInstData
{
    /// 场地长度，应该是18
    float field_length;
    /// 场地宽度，应该是12
    float field_width;
    /// 球门宽度
    float goal_area_width;
    /// 机器人最大速度
    float robot_max_speed;
    /// 机器人最大旋转速度
    float robot_max_rotate_speed;
    /// 机器人半径
    float robot_radius;
    /// 球半径
    float ball_radius;
    /// 限制区列表
    vector<RestrictedArea> restricted_area_list;
};

istream &operator>>(istream &in, ReceiveInstData &var)
{
    in >> var.field_length >> var.field_width >> var.goal_area_width;
    in >> var.robot_max_speed >> var.robot_max_rotate_speed;
    in >> var.robot_radius >> var.ball_radius;
    int n;
    in >> n;
    for (int i = 0; i < n; i += 1)
    {
        RestrictedArea ra;
        in >> ra;
        var.restricted_area_list.push_back(ra);
    }
    return in;
}

/// 状态信息，每秒接收100次（取决于判题器）
struct ReceiveData
{
    // 机器人信息
    float robot_x;
    float robot_z;
    float robot_speed;
    float robot_rotate_angle;
    // 球信息
    float ball_x;
    float ball_z;
    float ball_speed;
    float ball_rotate_angle;
    /// 机器人是否已经拿到球
    bool ball_caught;
};

istream &operator>>(istream &in, ReceiveData &var)
{
    int caught_int;
    in >> var.robot_x >> var.robot_z >> var.robot_speed >> var.robot_rotate_angle;
    in >> var.ball_x >> var.ball_z >> var.ball_speed >> var.ball_rotate_angle >> caught_int;
    var.ball_caught = (caught_int != 0);
    return in;
}

/// 要发送的信息，每秒发送100次（取决于判题器和程序运行状态）
struct SendData
{
    /// 前进速度
    float robot_speed;
    /// 旋转角速度
    float robot_rotate_speed;
    /// 是否有射门指令
    bool robot_kick;
};

ostream &operator<<(ostream &out, SendData &var)
{
    out << " " << var.robot_speed << " " << var.robot_rotate_speed << " " << (var.robot_kick ? 1 : 0) << " ";
    return out;
}

bool ready(ReceiveInstData &inst_data);
SendData update(ReceiveInstData &inst_data, ReceiveData &recv_data);

signed main()
{
    ReceiveInstData inst_data;
    cin >> inst_data;
    // Ready
    if (!ready(inst_data))
    {
        return 1;
    }
    cout << "OK"
         << " ";
    // Run
    while (true)
    {
        ReceiveData recv_data;
        cin >> recv_data;
        SendData send_data = update(inst_data, recv_data);
        cout << send_data << " "
             << "OK"
             << " ";
    }
    return 0;
}

// 以上部分一般不需要自行修改

/// 每次游戏开始时，传入场地信息等，每轮游戏只会执行一次
bool ready(ReceiveInstData &inst_data)
{
    return true;
}

float get_angle(float from_x, float from_z, float to_x, float to_z)
{
    if (from_z == 0.0 || from_z == -0.0)
    {
        from_z = 0.0000001;
    }
    float delta_x = to_x - from_x;
    float delta_z = to_z - from_z;
    float angle = -std::atan(delta_z / delta_x);
    if (delta_x < 0.0)
    {
        angle += PI;
    }
    while (angle > PI)
    {
        angle -= 2 * PI;
    }
    while (angle <= -PI)
    {
        angle += 2 * PI;
    }
    return angle;
}

/// 每次收到最新信息后执行。
/// 游戏运行过程中，正常情况下，每秒执行次数为游戏帧数（应该是每秒100次）
/// 机器人的抓球点：从机器人中心出发，方向为机器人前方，前进距离为机器人半径与球半径之和，最终到达的点。
SendData update(ReceiveInstData &inst_data, ReceiveData &recv_data)
{
    // 初始化值
    SendData send_data;
    send_data.robot_rotate_speed = 0.0;
    send_data.robot_speed = 0.0;
    send_data.robot_kick = false;
    // 计算与目标的角度
    float target_x = recv_data.ball_x;
    float target_z = recv_data.ball_z;
    if (recv_data.ball_caught)
    {
        target_x = inst_data.field_length / 2.0;
        target_z = 0.0;
    }
    float angle = get_angle(recv_data.robot_x, recv_data.robot_z, target_x, target_z);
    /// 角度差
    float delta_angle = angle - recv_data.robot_rotate_angle;
    float delta_angle_abs = std::abs(delta_angle);
    /// 机器人指定旋转速度
    float rotate_speed = (delta_angle >= 0.0) ? inst_data.robot_max_rotate_speed : -inst_data.robot_max_rotate_speed;
    // 检查角度
    if (delta_angle_abs < PI / 180.0 * 5.0)
    {
        // 差不多对准了
        send_data.robot_rotate_speed = 0.0;
        send_data.robot_speed = inst_data.robot_max_speed;
        if (recv_data.ball_caught)
        {
            // 有球就静止射门
            send_data.robot_speed = 0.0;
            send_data.robot_kick = true;
        }
    }
    else if (delta_angle_abs < PI / 2.0 - PI / 12.0)
    {
        // 在左前/右前
        send_data.robot_speed = inst_data.robot_max_speed;
        send_data.robot_rotate_speed = rotate_speed;
        if (recv_data.ball_caught)
        {
            // 有球就静止，但是先不踢
            send_data.robot_speed = 0.0;
        }
    }
    else
    {
        // 在左后/右后
        send_data.robot_speed = 0.0;
        send_data.robot_rotate_speed = rotate_speed;
    }
    // using std::cerr;
    // using std::endl;
    // cerr << "Target: " << target_x << " " << target_z;
    // cerr << " Go: " << send_data.robot_speed << " " << send_data.robot_rotate_speed << " " << send_data.robot_kick <<
    // endl;
    return send_data;
}
